Skip to content

Add testnet difficulty pause alert#5

Open
infraclaw-dash wants to merge 1 commit into
dashpay:masterfrom
infraclaw-dash:infraclaw/issue-4-difficulty-alert
Open

Add testnet difficulty pause alert#5
infraclaw-dash wants to merge 1 commit into
dashpay:masterfrom
infraclaw-dash:infraclaw/issue-4-difficulty-alert

Conversation

@infraclaw-dash

@infraclaw-dash infraclaw-dash commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Summary

  • parse Core best-block timestamp, hash, median time, and difficulty from getblockchaininfo
  • derive a dashboard banner for stale high-difficulty testnet tips
  • show Core difficulty and best block time in node details
  • add node:test coverage for parser metadata and alert detection

Closes #4

Notes

  • The alert is intentionally informational and does not change node health.
  • Current default detection is best block age >= 45 minutes and difficulty >= 1.

Tests

  • npm test
  • npm run lint
  • npm run build

Summary by CodeRabbit

  • New Features

    • Added difficulty stall detection alerts displayed on the dashboard
    • Extended node details view to show blockchain difficulty and best block timestamp
  • Tests

    • Added test coverage for difficulty alert detection
  • Chores

    • Added npm test script

@coderabbitai

coderabbitai Bot commented Jun 23, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c067583d-d063-498b-af16-64ba8c9d7ed8

📥 Commits

Reviewing files that changed from the base of the PR and between 3e8aaf3 and aa97671.

📒 Files selected for processing (8)
  • package.json
  • server/difficultyAlert.test.js
  • server/parser.js
  • server/parser.test.js
  • src/components/Dashboard.jsx
  • src/components/DifficultyAlert.jsx
  • src/components/NodeDetail.jsx
  • src/utils/difficultyAlert.js

📝 Walkthrough

Walkthrough

Adds testnet difficulty stall detection end-to-end: server/parser.js now extracts coreDifficulty, coreBestBlockTime, and coreMedianTime from dash-cli output; a new getDifficultyAlert utility selects the highest-height usable node and returns a structured alert when the block is stale and difficulty exceeds a threshold; a DifficultyAlert React component renders this alert; and Dashboard and NodeDetail are wired to display it.

Changes

Testnet Difficulty Stall Alert

Layer / File(s) Summary
Server parser: coreDifficulty, coreBestBlockTime, coreMedianTime
server/parser.js, server/parser.test.js
parseDashCliStatus reads chain.difficulty, chain.time, and chain.mediantime with finite-number guards; parser fixture gains bestblockhash, difficulty, time, and mediantime; a new test asserts all four parsed outputs.
getDifficultyAlert utility and server tests
src/utils/difficultyAlert.js, server/difficultyAlert.test.js, package.json
Exports DEFAULT_DIFFICULTY_ALERT_THRESHOLD, DEFAULT_STALE_BLOCK_SECONDS, and getDifficultyAlert; private helper filters usable nodes; function sorts by coreHeight, computes block age, and returns a typed alert or null. Four test cases cover no-stale, below-threshold, stale-alert, and multi-node selection. node --test script added to package.json.
DifficultyAlert component, NodeDetail rows, Dashboard wiring
src/components/DifficultyAlert.jsx, src/components/NodeDetail.jsx, src/components/Dashboard.jsx
DifficultyAlert formats difficulty and age and renders a styled stall message. NodeDetail adds Difficulty and Best Block Time rows. Dashboard calls getDifficultyAlert(nodes) and renders DifficultyAlert with the result.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐇 Hoppity-hop through the blockchain I go,
When difficulty spikes and blocks become slow,
I sniff out the stall with a keen little nose,
And flash up an alert so everyone knows!
The chain will resume when the ASIC departs—
Calm all the humans with my rabbit smarts. 🌟

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 12.50% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Add testnet difficulty pause alert' directly and specifically describes the main change: implementing a new alert feature for testnet difficulty issues.
Linked Issues check ✅ Passed The PR fully addresses issue #4 by implementing a dashboard notification for difficulty-induced stalls, displaying difficulty and block age metrics, with detection at 45+ minutes staleness and 1+ difficulty threshold.
Out of Scope Changes check ✅ Passed All changes are within scope: new alert detection logic, parser field additions for blockchain metadata, UI components for displaying alerts and node details, and comprehensive test coverage.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Notify of difficulty-induced lack of block production

1 participant